package cn.bs.busuo.account.dao.persist.repository.impl;

import cn.bs.busuo.account.dao.persist.mapper.PermissionMapper;
import cn.bs.busuo.account.dao.persist.repository.IPermissionRepository;
import cn.bs.busuo.account.pojo.entity.UserRole;
import cn.bs.busuo.account.pojo.param.Role;
import cn.bs.busuo.account.pojo.vo.UserRoleVO;
import cn.bs.busuo.account.pojo.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author 0.0
 */
@Repository
public class PermissionRepositoryImpl implements IPermissionRepository {
    @Autowired
    private PermissionMapper permissionMapper;

    //删除管理员
    @Override
    public void deleteById(Role role) {
        permissionMapper.deleteById(role);
    }

    //新增管理员
    @Override
    public void insertById(UserRole userRole) {
        permissionMapper.insert(userRole);
    }

    //新增工作人员
    @Override
    public void addOperator(UserRole userRole) {
        permissionMapper.insert(userRole);
    }

    //删除工作人员
    @Override
    public void delectOperator(Role role) {
        permissionMapper.deleteById(role);
    }

    //查找权限
    @Override
    public List<UserRoleVO> selectById(Long userId) {
        return permissionMapper.selectById(userId);
    }

    @Override
    public UserVO selectUser(Long id) {
        return permissionMapper.selectUser(id);
    }

}
